<?php require_once('../../../core/import.php');?>
<?php User::Permission('SLIDE_EDIT'); ?>
<?php
    if($_SERVER['REQUEST_METHOD']=='POST')
    {
		#获取参数
		$Collection_ID=explode(',',Functions::FormArgs('ID'));
		$Class=strtoupper(Functions::FormArgs('Class'));

		#更新数据
		foreach($Collection_ID as $Key=>$Value)
		{
			if($Value!=NULL)
			{
				$Title=Functions::FormArgs('Title_'.$Value);
				$URL=Functions::FormArgs('URL_'.$Value);
				
				DB::UpdateRowByID('slide','ID:'.$Value,array
				(
					'Title'=>$Title,
					'URL'=>$URL
				));
			}
		}        		
		
		#生成文件
		$Data=DB::PGetRows('select * from slide where Class=? order by ID asc',array($Class));
		$XML='<?xml version="1.0" encoding="utf-8"?><bcaster autoPlayTime="3">';
		{
			foreach($Data as $Row)
			{
				$XML=$XML.'<item item_url="'.Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$Row['PictureFilename'].'" link="'.$Row['URL'].'" itemtitle=""></item>';
			}
		}
		$XML=$XML.'</bcaster>';	
		$fp=fopen(ROOT.'/data/slide/'.strtolower($Class).'.xml','w');
		{
			fwrite($fp,$XML);
			fclose($fp);
		}
		$fp=NULL;	
	}
?>